﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Small.SmortHtmlHelper.UI;
using Small.Util.Reflection;


namespace Small.SmortHtmlHelper.Validate
{
   public class TreeMenuOptions<T>:BaseExpress
    {



        private Expression<Func<T, object>> key;

        public Expression<Func<T, object>> Key
        {
            get { return key; }
            set { key = value; }
        }
        private Expression<Func<T, object>> expand;

        public Expression<Func<T, object>> Expand
        {
            get { return expand; }
            set { expand = value; }
        }
        private Expression<Func<T, object>> parentID;

        public Expression<Func<T, object>> ParentID
        {
            get { return parentID; }
            set { parentID = value; }
        }
        private Expression<Func<T, object>>[] fields;

        public Expression<Func<T, object>>[] Fields
        {
            get { return fields; }
            set { fields = value; }
        }
       
       //数据源
        private IEnumerable<T> list ;

       /// <summary>
       /// 数据源
       /// </summary>
        public IEnumerable<T> List
        {
            get { return list; }
            set { list = value; }
        }
       
       
        private Int32 level;
       /// <summary>
       /// 深度
       /// </summary>
        public Int32 Level
        {
            get { return level; }
            set { level = value; }
        }

 

       //遍历
        private void ForEach(T t) 
        {

            if (String.IsNullOrEmpty(key.Name)) {
                throw new Exception("The key can't be empty");
            }
            Dictionary<string, string> anonymousNameList = DefinationProperties.GetProperties<T>(t);
            foreach (var item in anonymousNameList.Keys)
            {



                if (item.ToUpper().Trim() == GetExpressName(key).ToUpper().Trim())
                {

                }
                else
                {
                    var name = item;//名字
                    string value = anonymousNameList[item];//值
                }
            }
        }
    }
}
